import { PlusSquareOutlined, MinusSquareOutlined } from '@ant-design/icons-vue';
// 自定义table子表格或者子节点展开图标
export const expandIcon = (props, field: string) => {
    const { expanded, record, onExpand } = props;
    // 自定义子节点是因为需要手动加载优化速度，无数据则无需展示+按钮
    // 自定义子表格是因为需要动态判断子表格是否有数据，无数据则无需展示+按钮
    let res = true;
    if (field === 'sonRequestInfos') {
        res = +record.stage >= 4 && record.isSplit === '是' && record.relateRequest === 0;
    } else {
        res = record[field] && record[field].length;
    }
    if (res) {
        // 展开显示图标
        if (expanded) {
            return <span style="margin-right:6px;cursor:pointer"
                onClick={(e) => {
                    onExpand(record, e);
                }}>
                <MinusSquareOutlined />
            </span>;
        }
        // 收起显示图标
        else {
            return <span style="margin-right:6px;cursor:pointer"
                onClick={(e) => {
                    onExpand(record, e);
                }
                }
            >
                <PlusSquareOutlined />
            </span>;
        }
    } else {
        // 判断是否是孩子节点来控制缩进样式
        if (field === 'sonRequestInfos') {
            return record.relateRequest > 0 ? <a style="margin-left:0px" /> : '';
        }
        return '';
    }
};